Skip to content

file-system: drop redundant quotes around PathFmt and assert relative paths#15329

Merged
Ericson2314 merged 2 commits intoNixOS:masterfrom
obsidiansystems:path-review-followup
Feb 25, 2026
Merged

file-system: drop redundant quotes around PathFmt and assert relative paths#15329
Ericson2314 merged 2 commits intoNixOS:masterfrom
obsidiansystems:path-review-followup

Conversation

@amaanq
Copy link
Member

@amaanq amaanq commented Feb 24, 2026

@github-actions github-actions bot added the store Issues and pull requests concerning the Nix store label Feb 24, 2026
@amaanq amaanq force-pushed the path-review-followup branch from 9387dd6 to 928de25 Compare February 24, 2026 21:05
@github-actions github-actions bot added new-cli Relating to the "nix" command repl The Read Eval Print Loop, "nix repl" command and debugger labels Feb 24, 2026
@Ericson2314 Ericson2314 force-pushed the path-review-followup branch 2 times, most recently from 185f679 to 369d09b Compare February 24, 2026 23:16
{
assert(isInStore(storePath));
return getRealStoreDir() + "/" + std::string(storePath, storeDir.size() + 1);
return (getRealStoreDir() / std::string(storePath, storeDir.size() + 1)).string();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems quite janky. What if storePath has some trailing slashes after storeDir? This would discard the LHS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think storePath is always canonical here, because it comes from printStorePath which produces storeDir + "/" + storePath.to_string(), so there shouldn't be double or trailing slashes. The StorePath itself was validated in parseStorePath, which calls canonPath

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we can't accept StorePath here? I guess it would be a rather big change though...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we could though I guess it would be a much larger change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe not, because there's one call by derivation-builder.cc on line 1866 that passes in finalDestPath + ".check"..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, it's not exactly a valid store path I suppose, but maybe we can hack it in in a way that's not that janky

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, made it a separate commit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is very nice outcome!

@Ericson2314 Ericson2314 disabled auto-merge February 24, 2026 23:29
- file-system: drop redundant quotes around `PathFmt` and assert relative paths
- libutil, libstore: fix mingw cross-compilation breakages
@amaanq amaanq force-pushed the path-review-followup branch from 369d09b to f4dfbca Compare February 25, 2026 00:10
@amaanq amaanq force-pushed the path-review-followup branch from c27a99b to d5dafb3 Compare February 25, 2026 03:25
mkstemp(const_cast<char *>(tmpl.c_str()))
#endif
);
// `mkstemp` modifies the string to contain the actual filename.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're being good now :)

Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested both builds

@Ericson2314 Ericson2314 added this pull request to the merge queue Feb 25, 2026
Merged via the queue into NixOS:master with commit 16f10c1 Feb 25, 2026
14 checks passed
@Ericson2314 Ericson2314 deleted the path-review-followup branch February 25, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command repl The Read Eval Print Loop, "nix repl" command and debugger store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants